package com.example.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;



/**
 * Create with Intellij idea
 * User:鲁智明
 * Date:2018/11/25
 * Time:18:33
 */

@Configuration
@EnableSwagger2   // 开启Swagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2).
                 //生成Api扫包范围
                apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.basePackage("com.example")).paths(PathSelectors.any()).build();

    }

    //创建API文档信息
    private ApiInfo apiInfo() {
        //title 文档标题
        //description 文档描述
        //termsOfServiceUrl 网址
        //version 文档版本号
        return new ApiInfoBuilder().title("微服务电商系统").description("我正在学习搭建SpringBoot2.0整合Swagger2.0")
                .termsOfServiceUrl("http://www.itmayiedu.com")
                // .contact(contact)
                .version("1.0").build();
    }
}
